package com.souche.employment.mapper;

import com.souche.employment.domain.DepartmentDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * DepartmentMapper.java created at 2017年8月9日 下午2:23:36
 * <p>
 * Ray [email:rayinhangzhou@hotmail.com]
 * Revision History
 * Date            Programmer                   Notes
 * ----------------------------------------------------------
 **/
@Mapper
public interface DepartmentMapper {

    @SelectProvider(type = SqlProvider.class, method = "findDeps")
    @Results({
            @Result(property = "dateCreate", column = "date_create"),
            @Result(property = "dateUpdate", column = "date_update")
    })
    List<DepartmentDO> findDeps(@Param("level") String level, @Param("father") String father);


    @Insert("insert into department (id, level, name, father, date_create) values(#{id}, #{level}, #{name}, #{father}, #{dateCreate})")
    void addDep(DepartmentDO departmentDO);

    @Select("select id, name, level, father from department where id= #{id}")
    DepartmentDO getDep(@Param("id") String id);

}
